<?php
/* -----------------------------------------------------------------
 *                        Aveghe My Blog
 * -----------------------------------------------------------------
 * Aveghe My Blog: made your blog easy!
 * Copyright (C) 2008 Elia Contini
 * 
 * Aveghe My Blog is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 * 
 * Aveghe My Blog is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
 * MA 02110-1301, USA.
 */

error_reporting (E_ALL | E_STRICT);
ini_set('display_errors', 'on');
ini_set('include_path'  , get_include_path().PATH_SEPARATOR.'lib'.PATH_SEPARATOR.'aveghe/models');

require_once('Zend/Loader.php');
require_once('aveghe/conf/conf.php');

Zend_Loader::registerAutoload();

new Zend_Session_Namespace('avegheNS');

$parameters = array(
					'host'     => DATABASE_HOST,
     				'username' => DATABASE_USERNAME,
    				'password' => DATABASE_PASSWORD,
    				'dbname'   => DATABASE_NAME,
				   );

try
	{
    	$db = Zend_Db::factory('Pdo_Mysql', $parameters);
    	$db->getConnection();
    	
    	Zend_Registry::set('db', $db);                            // database handler
    	Zend_Registry::set('tablePrefix', DATABASE_TABLE_PREFIX); // table prefix
    	
    	$sitePref = new Preference();
    	$preferences = $sitePref->getAll();
    	
    	Zend_Registry::set('preferences', $preferences);          // preferences
    	
    	Zend_Controller_Front::run('aveghe/controllers');
	}
catch (Zend_Db_Adapter_Exception $e)
	{
    	// perhaps a failed login credential, or perhaps the RDBMS is not running
    	print($e->getMessage());
	}
catch (Zend_Exception $e)
	{
    	// perhaps factory() failed to load the specified Adapter class
    	print($e->getMessage());
	}
?>